<?php
$a = Foto::model()->cout3Foto();
$print = '';
$print2 = '';

if(!isset($_GET['Foto_page'])) $page = 1;
else $page =$_GET['Foto_page'];

if($a % 3 == 2) $print2 = '</tr></table>';

if( $a  + 9 * ($page - 1) - 2 == Foto::model()->getCounts()){
    for($a = 0; $a < (Foto::model()->getCounts() % 3) - 1; $a ++) $print2 .= '<td style="width=33%"></td>';
    $print2 .= '</tr></table>';
}

if($a % 3 == 0) {
    $print = '<table><tr>';
}

?>
<? echo $print ?>
<td style="width:33%;">
<div class="view" style="width: 100px; ">

    <a href="<?php echo $this->createUrl("foto/view", array('id'=>$data->id_foto)) ?>"><img WIDTH="100" HEIGHT="100" src="media/foto/<?php echo $data->link?>" /></a>

</div>
</td>
<? echo $print2;
?>